/*
 * Created on 30.08.2004
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package org.opencube.oms.test;

/**
 * @author cw
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
import java.io.*;
import java.net.*;
import java.security.*;

// Extend Browser to use SSL
public class SecureBrowser extends BasicBrowser {
  // Must supply URL in command line
  public static void main(String[] args) throws Exception {
    
   // SecureBrowser browser = new SecureBrowser("https://omsws.nmm.de.nmm.de/servlet/dservice");
 	//SecureBrowser browser = new SecureBrowser("https://www.verisign.com");
	//  SecureBrowser browser = new SecureBrowser("https://localhost/licence.php");
	  SecureBrowser browser = new SecureBrowser("https://license.nmm.de/");
 	
     browser.run();
   }
   // Construct a SecureBrowser
  
  	 public void findTrustStore() {
  	  String trustStore = System.getProperty("javax.net.ssl.trustStore");
  	  if(trustStore == null) 
  	   System.out.println("javax.net.ssl.trustStore is not defined");
  	  else System.out.println("javax.net.ssl.trustStore = " + trustStore);
  	 }
  	


   public SecureBrowser(String urlString) {
    super(urlString);
     // Register JSSE
    Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
    System.setProperty("javax.net.ssl.trustStore","C:/Programme/Java/jre1.5.0_02/lib/security/cacerts");
    // System.setProperty("javax.net.ssl.trustStorePassword","changeit");
    com.sun.net.ssl.HostnameVerifier hv=new com.sun.net.ssl.HostnameVerifier() {
     	public boolean verify(String urlHostname, String certHostname) {
     	System.out.println("WARNING: Hostname is not matched for cert.");
     	return true;
     	}
     	};
	com.sun.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier(hv);
    findTrustStore();
     
     
     // Here's the trick!
     // Simply set the protocol handler property to use SSL.
     System.setProperty("java.protocol.handler.pkgs",
       "com.sun.net.ssl.internal.www.protocol");
   }
}


